<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/activeqt/container/qaxscript.cpp -->
<head>
  <title>Qt 4.3: QAxScriptManager Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QAxScriptManager Class Reference<br /><sup><sup>[<a href="qaxcontainer.html">QAxContainer</a> module]</sup></sup></h1>
<p>The QAxScriptManager class provides a bridge between application objects and script code. <a href="#details">More...</a></p>
<pre> #include &lt;QAxScriptManager&gt;</pre><p>Inherits <a href="qobject.html">QObject</a>.</p>
<ul>
<li><a href="qaxscriptmanager-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qaxscriptmanager.html#QAxScriptManager">QAxScriptManager</a></b> ( QObject * <i>parent</i> = 0 )</li>
<li><div class="fn"/><b><a href="qaxscriptmanager.html#dtor.QAxScriptManager">~QAxScriptManager</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qaxscriptmanager.html#addObject">addObject</a></b> ( QAxBase * <i>object</i> )</li>
<li><div class="fn"/>void <b><a href="qaxscriptmanager.html#addObject-2">addObject</a></b> ( QObject * <i>object</i> )</li>
<li><div class="fn"/>QVariant <b><a href="qaxscriptmanager.html#call">call</a></b> ( const QString &amp; <i>function</i>, const QVariant &amp; <i>var1</i> = QVariant(), const QVariant &amp; <i>var2</i> = QVariant(), const QVariant &amp; <i>var3</i> = QVariant(), const QVariant &amp; <i>var4</i> = QVariant(), const QVariant &amp; <i>var5</i> = QVariant(), const QVariant &amp; <i>var6</i> = QVariant(), const QVariant &amp; <i>var7</i> = QVariant(), const QVariant &amp; <i>var8</i> = QVariant() )</li>
<li><div class="fn"/>QVariant <b><a href="qaxscriptmanager.html#call-2">call</a></b> ( const QString &amp; <i>function</i>, QList&lt;QVariant&gt; &amp; <i>arguments</i> )</li>
<li><div class="fn"/>QStringList <b><a href="qaxscriptmanager.html#functions">functions</a></b> ( QAxScript::FunctionFlags <i>flags</i> = QAxScript::FunctionNames ) const</li>
<li><div class="fn"/>QAxScript * <b><a href="qaxscriptmanager.html#load">load</a></b> ( const QString &amp; <i>code</i>, const QString &amp; <i>name</i>, const QString &amp; <i>language</i> )</li>
<li><div class="fn"/>QAxScript * <b><a href="qaxscriptmanager.html#load-2">load</a></b> ( const QString &amp; <i>file</i>, const QString &amp; <i>name</i> )</li>
<li><div class="fn"/>QAxScript * <b><a href="qaxscriptmanager.html#script">script</a></b> ( const QString &amp; <i>name</i> ) const</li>
<li><div class="fn"/>QStringList <b><a href="qaxscriptmanager.html#scriptNames">scriptNames</a></b> () const</li>
</ul>
<ul>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="signals"></a>
<h3>Signals</h3>
<ul>
<li><div class="fn"/>void <b><a href="qaxscriptmanager.html#error">error</a></b> ( QAxScript * <i>script</i>, int <i>code</i>, const QString &amp; <i>description</i>, int <i>sourcePosition</i>, const QString &amp; <i>sourceText</i> )</li>
</ul>
<ul>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h3>Static Public Members</h3>
<ul>
<li><div class="fn"/>bool <b><a href="qaxscriptmanager.html#registerEngine">registerEngine</a></b> ( const QString &amp; <i>name</i>, const QString &amp; <i>extension</i>, const QString &amp; <i>code</i> = QString() )</li>
<li><div class="fn"/>QString <b><a href="qaxscriptmanager.html#scriptFileFilter">scriptFileFilter</a></b> ()</li>
</ul>
<ul>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QAxScriptManager class provides a bridge between application objects and script code.</p>
<p>The QAxScriptManager acts as a bridge between the COM objects embedded in the Qt application through <a href="qaxobject.html">QAxObject</a> or <a href="qaxwidget.html">QAxWidget</a>, and the scripting languages available through the Windows Script technologies, usually JScript and VBScript.</p>
<p>Create one QAxScriptManager for each separate document in your application, and add the COM objects the scripts need to access using <a href="qaxscriptmanager.html#addObject">addObject</a>(). Then <a href="qaxscriptmanager.html#load">load</a>() the script sources and invoke the functions using <a href="qaxscriptmanager.html#call">call</a>().</p>
<p><b>Warning:</b> This class is not available with the bcc5.5 and MingW compilers.</p>
<p>See also <a href="qaxscript.html">QAxScript</a>, <a href="qaxscriptengine.html">QAxScriptEngine</a>, <a href="qaxbase.html">QAxBase</a>, and <a href="activeqt.html">ActiveQt Framework</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QAxScriptManager"></a>QAxScriptManager::QAxScriptManager ( <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
<p>Creates a <a href="qaxscriptmanager.html">QAxScriptManager</a> object. <i>parent</i> is passed on to the <a href="qobject.html">QObject</a> constructor.</p>
<p>It is usual to create one <a href="qaxscriptmanager.html">QAxScriptManager</a> for each document in an application.</p>
<h3 class="fn"><a name="dtor.QAxScriptManager"></a>QAxScriptManager::~QAxScriptManager ()</h3>
<p>Destroys the objects, releasing all allocated resources.</p>
<h3 class="fn"><a name="addObject"></a>void QAxScriptManager::addObject ( <a href="qaxbase.html">QAxBase</a> * <i>object</i> )</h3>
<p>Adds <i>object</i> to the manager. Scripts handled by this manager can access the object in the code using the object's <a href="qobject.html#objectName-prop">objectName</a> property.</p>
<p>You must add all the necessary objects before loading any scripts.</p>
<h3 class="fn"><a name="addObject-2"></a>void QAxScriptManager::addObject ( <a href="qobject.html">QObject</a> * <i>object</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Adds a generic COM wrapper for <i>object</i> to the manager. <i>object</i> must be exposed as a COM object using the functionality provided by the <a href="qaxserver.html">QAxServer</a> module. Applications using this function you must link against the qaxserver library.</p>
<h3 class="fn"><a name="call"></a><a href="qvariant.html">QVariant</a> QAxScriptManager::call ( const <a href="qstring.html">QString</a> &amp; <i>function</i>, const <a href="qvariant.html">QVariant</a> &amp; <i>var1</i> = QVariant(), const <a href="qvariant.html">QVariant</a> &amp; <i>var2</i> = QVariant(), const <a href="qvariant.html">QVariant</a> &amp; <i>var3</i> = QVariant(), const <a href="qvariant.html">QVariant</a> &amp; <i>var4</i> = QVariant(), const <a href="qvariant.html">QVariant</a> &amp; <i>var5</i> = QVariant(), const <a href="qvariant.html">QVariant</a> &amp; <i>var6</i> = QVariant(), const <a href="qvariant.html">QVariant</a> &amp; <i>var7</i> = QVariant(), const <a href="qvariant.html">QVariant</a> &amp; <i>var8</i> = QVariant() )</h3>
<p>Calls <i>function</i>, passing the parameters <i>var1</i>, <i>var1</i>, <i>var2</i>, <i>var3</i>, <i>var4</i>, <i>var5</i>, <i>var6</i>, <i>var7</i> and <i>var8</i> as arguments and returns the value returned by the function, or an invalid <a href="qvariant.html">QVariant</a> if the function does not return a value or when the function call failed. The call returns when the script's execution has finished.</p>
<p>In most script engines the only supported parameter type is &quot;const <a href="qvariant.html">QVariant</a>&amp;&quot;, for example, to call a JavaScript function</p>
<pre> function setNumber(number)
 {
     n = number;
 }</pre>
<p>use</p>
<pre>     QValueList args;
     args &lt;&lt; 5;
     script-&gt;call(&quot;setNumber(const QVariant&amp;)&quot;, args);</pre>
<p>As with <a href="qaxbase.html#dynamicCall">dynamicCall</a> the parameters can directly be embedded in the function string.</p>
<pre>     script-&gt;call(&quot;setNumber(5)&quot;);</pre>
<p>However, this is slower.</p>
<p>Functions provided by script engines that don't support introspection are not available and must be called directly using <a href="qaxscript.html#call">QAxScript::call</a>() on the respective <a href="qaxscriptmanager.html#script">script</a> object.</p>
<p>Note that calling this function can be significantely slower than using call() on the respective <a href="qaxscript.html">QAxScript</a> directly.</p>
<h3 class="fn"><a name="call-2"></a><a href="qvariant.html">QVariant</a> QAxScriptManager::call ( const <a href="qstring.html">QString</a> &amp; <i>function</i>, <a href="qlist.html">QList</a>&lt;<a href="qvariant.html">QVariant</a>&gt; &amp; <i>arguments</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Calls <i>function</i> passing <i>arguments</i> as parameters, and returns the result. Returns when the script's execution has finished.</p>
<h3 class="fn"><a name="error"></a>void QAxScriptManager::error ( <a href="qaxscript.html">QAxScript</a> * <i>script</i>, int <i>code</i>, const <a href="qstring.html">QString</a> &amp; <i>description</i>, int <i>sourcePosition</i>, const <a href="qstring.html">QString</a> &amp; <i>sourceText</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when an execution error occurred while running <i>script</i>.</p>
<p><i>code</i>, <i>description</i>, <i>sourcePosition</i> and <i>sourceText</i> contain information about the execution error.</p>
<p><b>Warning:</b> Do not delete <i>script</i> in a slot connected to this signal. Use <a href="qobject.html#deleteLater">deleteLater</a>() instead.</p>
<h3 class="fn"><a name="functions"></a><a href="qstringlist.html">QStringList</a> QAxScriptManager::functions ( <a href="qaxscript.html#FunctionFlags-enum">QAxScript::FunctionFlags</a> <i>flags</i> = QAxScript::FunctionNames ) const</h3>
<p>Returns a list with all the functions that are available. Functions provided by script engines that don't support introspection are not included in the list. The functions are either provided with full prototypes or only as names, depending on the value of <i>flags</i>.</p>
<h3 class="fn"><a name="load"></a><a href="qaxscript.html">QAxScript</a> * QAxScriptManager::load ( const <a href="qstring.html">QString</a> &amp; <i>code</i>, const <a href="qstring.html">QString</a> &amp; <i>name</i>, const <a href="qstring.html">QString</a> &amp; <i>language</i> )</h3>
<p>Loads the script source <i>code</i> using the script engine for <i>language</i>. The script can later be referred to using its <i>name</i> which should not be empty.</p>
<p>The function returns a pointer to the script for the given <i>code</i> if the <i>code</i> was loaded successfully; otherwise it returns 0.</p>
<p>If <i>language</i> is empty it will be determined heuristically. If <i>code</i> contains the string &quot;End Sub&quot; it will be interpreted as VBScript, otherwise as JScript. Additional script engines can be registered using <a href="qaxscriptmanager.html#registerEngine">registerEngine</a>().</p>
<p>You must add all the objects necessary (using <a href="qaxscriptmanager.html#addObject">addObject</a>()) <i>before</i> loading any scripts. If <i>code</i> declares a function that is already available (no matter in which language) the first function is overloaded and can no longer be called via <a href="qaxscriptmanager.html#call">call</a>(); but it will still be available by calling its <a href="qaxscriptmanager.html#script">script</a> directly.</p>
<p>See also <a href="qaxscriptmanager.html#addObject">addObject</a>(), <a href="qaxscriptmanager.html#scriptNames">scriptNames</a>(), and <a href="qaxscriptmanager.html#functions">functions</a>().</p>
<h3 class="fn"><a name="load-2"></a><a href="qaxscript.html">QAxScript</a> * QAxScriptManager::load ( const <a href="qstring.html">QString</a> &amp; <i>file</i>, const <a href="qstring.html">QString</a> &amp; <i>name</i> )</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Loads the source code from the <i>file</i>. The script can later be referred to using its <i>name</i> which should not be empty.</p>
<p>The function returns a pointer to the script engine for the code in <i>file</i> if <i>file</i> was loaded successfully; otherwise it returns 0.</p>
<p>The script engine used is determined from the file's extension. By default &quot;.js&quot; files are interpreted as JScript files, and &quot;.vbs&quot; and &quot;.dsm&quot; files are interpreted as VBScript. Additional script engines can be registered using <a href="qaxscriptmanager.html#registerEngine">registerEngine</a>().</p>
<h3 class="fn"><a name="registerEngine"></a>bool QAxScriptManager::registerEngine ( const <a href="qstring.html">QString</a> &amp; <i>name</i>, const <a href="qstring.html">QString</a> &amp; <i>extension</i>, const <a href="qstring.html">QString</a> &amp; <i>code</i> = QString() )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Registers the script engine called <i>name</i> and returns true if the engine was found; otherwise does nothing and returns false.</p>
<p>The script engine will be used when loading files with the given <i>extension</i>, or when loading source code that contains the string <i>code</i>.</p>
<h3 class="fn"><a name="script"></a><a href="qaxscript.html">QAxScript</a> * QAxScriptManager::script ( const <a href="qstring.html">QString</a> &amp; <i>name</i> ) const</h3>
<p>Returns the script called <i>name</i>.</p>
<p>You can use the returned pointer to call functions directly through <a href="qaxscript.html#call">QAxScript::call</a>(), to access the script engine directly, or to delete and thus unload the script.</p>
<h3 class="fn"><a name="scriptFileFilter"></a><a href="qstring.html">QString</a> QAxScriptManager::scriptFileFilter ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns a file filter listing all the supported script languages. This filter string is convenient for use with <a href="qfiledialog.html">QFileDialog</a>.</p>
<h3 class="fn"><a name="scriptNames"></a><a href="qstringlist.html">QStringList</a> QAxScriptManager::scriptNames () const</h3>
<p>Returns a list with the names of all the scripts.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
